#include "../mtcp_module.h"


FLDI::FLDI()
{
	memset(&_req, 0, sizeof(_req));
	_req.POS_X = 125;
}


FLDI::~FLDI()
{
}

int FLDI::setvalue(char *what, char* value)
{
	if (0 == strcmp(what, "IMG_INDEX")){
		IMG_INDEX(atoi(value));
		return 0;
	}
	if (0 == strcmp(what, "IMG_WIDTH")){
		IMG_WIDTH(atoi(value));
		return 0;
	}
	if (0 == strcmp(what, "IMG_HEIGHT")){
		IMG_HEIGHT(atoi(value));
		return 0;
	}
	if (0 == strcmp(what, "IMG_SIZE")){
		IMG_SIZE(atoi(value));
		return 0;
	}
	if (0 == strcmp(what, "POS_X")){
		POS_X(atoi(value));
		return 0;
	}
	if (0 == strcmp(what, "POS_Y")){
		POS_Y(atoi(value));
		return 0;
	}
	if (0 == strcmp(what, "POWER_TO_PIXEL_RATIO")){
		POWER_TO_PIXEL_RATIO(atof(value));
		return 0;
	}

	return -1;
}

int FLDI::SendFLDI()
{
	int ret = SendFrame(kMTCP_CTRL_FLDI, (void*)&_req, sizeof(_req), nullptr, 0);

	 tMTCP_payload_TEST_RSP rep;
	 RecvResponse(&rep, sizeof(rep));

	return ret;
}
